import 'package:flutter_admin/utils/utils.dart';

class ProductPlateconsumption {

  String? id;
  String? productId;
  String? productName;
  String? thicknessId;
  String? thicknessName;
  num? length;
  num? width;
  num? weight;
  num? consumednumber;
  String? stationId;
  String? stationName;
  String? filledUid;
  String? filledName;
  String? filledDate;
  String? filledDateStart;
  String? filledDateEnd;
  String? remark;
  String? createUid;
  String? createDate;
  String? writeUid;
  String? writeName;
  String? writeDate;

  ProductPlateconsumption({
    this.id,
    this.productId,
    this.productName,
    this.thicknessId,
    this.thicknessName,
    this.length,
    this.width,
    this.weight,
    this.consumednumber,
    this.stationId,
    this.stationName,
    this.filledUid,
    this.filledName,
    this.filledDate,
    this.filledDateStart,
    this.filledDateEnd,
    this.remark,
    this.createUid,
    this.createDate,
    this.writeUid,
    this.writeName,
    this.writeDate,
  });

  ProductPlateconsumption copyWith({
    String? id,
    String? productId,
    String? thicknessId,
    num? length,
    num? width,
    num? consumednumber,
    String? stationId,
    String? filledUid,
    String? filledDate,
    String? remark,
    String? createUid,
    String? createDate,
    String? writeUid,
    String? writeDate,
  }) {
    return new ProductPlateconsumption(
      id: id ?? this.id,
      productId: productId ?? this.productId,
      thicknessId: thicknessId ?? this.thicknessId,
      length: length ?? this.length,
      width: width ?? this.width,
      consumednumber: consumednumber ?? this.consumednumber,
      stationId: stationId ?? this.stationId,
      filledUid: filledUid ?? this.filledUid,
      filledDate: filledDate ?? this.filledDate,
      remark: remark ?? this.remark,
      createUid: createUid ?? this.createUid,
      createDate: createDate ?? this.createDate,
      writeUid: writeUid ?? this.writeUid,
      writeDate: writeDate ?? this.writeDate,
    );
  }

  @override
  String toString() {
    return '''ProductPlateconsumption{
      id: $id,
      productId: $productId,
      thicknessId: $thicknessId,
      length: $length,
      width: $width,
      consumednumber: $consumednumber,
      stationId: $stationId,
      filledUid: $filledUid,
      filledDate: $filledDate,
      remark: $remark,
      createUid: $createUid,
      createDate: $createDate,
      writeUid: $writeUid,
      writeDate: $writeDate,
    }''';
  }

  @override
  bool operator ==(Object other) => identical(this, other) || (
      other is ProductPlateconsumption &&
          runtimeType == other.runtimeType
          && id== other.id
          && productId== other.productId
          && thicknessId== other.thicknessId
          && length== other.length
          && width== other.width
          && consumednumber== other.consumednumber
          && stationId== other.stationId
          && filledUid== other.filledUid
          && filledDate== other.filledDate
          && remark== other.remark
          && createUid== other.createUid
          && createDate== other.createDate
          && writeUid== other.writeUid
          && writeDate== other.writeDate
   );


  factory ProductPlateconsumption.fromMap(Map<String, dynamic> map) {
    return new ProductPlateconsumption(
      id: map['id']!=false?map['id'].toString() as String?:"",
      productId: map['product_id']!=false?map['product_id'][0].toString() as String?:"",
      productName: map['product_id']!=false?map['product_id'][1].toString() as String?:"",
      thicknessId: map['thickness_id']!=false?map['thickness_id'][0].toString() as String?:"",
      thicknessName: map['thickness_id']!=false?map['thickness_id'][1].toString() as String?:"",
      length: map['length']!=false?map['length']:0,
      width: map['width']!=false?map['width']:0,
      weight: map['weight']!=false?map['weight']:0,
      consumednumber: map['consumednumber']!=false?map['consumednumber']:0,
      stationId: map['station_id']!=false?map['station_id'][0].toString() as String?:"",
      stationName: map['station_id']!=false?map['station_id'][1].toString() as String?:"",
      filledUid: map['filled_uid']!=false?map['filled_uid'][0].toString() as String?:"",
      filledName: map['filled_uid']!=false?map['filled_uid'][1].toString() as String?:"",
      filledDate: map['filled_date']!=false?map['filled_date'].toString() as String?:"",
      remark: map['remark']!=false?map['remark'].toString() as String?:"",
      createUid: map['create_uid']!=false?map['create_uid'].toString() as String?:"",
      createDate: map['create_date']!=false?map['create_date'].toString() as String?:"",
      writeUid: map['write_uid']!=false?map['write_uid'][0].toString() as String?:"",
      writeName: map['write_uid']!=false?map['write_uid'][1].toString() as String?:"",
      writeDate: map['write_date']!=false?Utils.timeUTC(map['write_date']):"",
    );
  }

  Map<String, dynamic> toMap() {
    // ignore: unnecessary_cast
    return {
      'id': this.id,
      'productId': this.productId,
      'productName': this.productName,
      'thicknessId': this.thicknessId,
      'thicknessName': this.thicknessName,
      'length': this.length,
      'width': this.width,
      'weight': this.weight,
      'consumednumber': this.consumednumber,
      'stationId': this.stationId,
      'stationName': this.stationName,
      'filledUid': this.filledUid,
      'filledName': this.filledName,
      'filledDate': this.filledDate,
      'remark': this.remark,
      'createUid': this.createUid,
      'createDate': this.createDate,
      'writeUid': this.writeUid,
      'writeName': this.writeName,
      'writeDate': this.writeDate,
    } as Map<String, dynamic>;
  }

  List toDomainList() {
    List list = [
      if(this.productName!=null&&this.productName!='')['name','like','%${this.productName}%'],
      if(this.filledName!=null&&this.filledName!='')['user','like','%${this.filledName}%'],
      if(this.filledDateStart!=null&&this.filledDateStart!='')['stater','=',this.filledDateStart],
      if(this.filledDateEnd!=null&&this.filledDateEnd!='')['end','=',this.filledDateEnd],
    ];
    //if(list.length==0){
    //  list.add(['id','!=',null]);
    //}
    // ignore: unnecessary_cast
    return list;
  }

  Map<String, dynamic> toOdooMap() {
    // ignore: unnecessary_cast
    return {
      'id': this.id,
      'product_id': this.productId,
      'thickness_id': this.thicknessId,
      'length': this.length,
      'width': this.width,
      // 'weight': this.weight,
      'consumednumber': this.consumednumber,
      'station_id': this.stationId,
      'filled_uid': this.filledUid,
      'filled_date': this.filledDate,
      'remark': this.remark,
      'create_uid': this.createUid,
      'create_date': this.createDate,
      'write_uid': this.writeUid,
      'write_date': this.writeDate,
    } as Map<String, dynamic>;
  }

//</editor-fold>

}